package com.xpgk.mvc.bsendMessage;


import java.io.File;

import com.jfinal.kit.HashKit;
import com.jfinal.kit.PropKit;

public class JpxtConstants {
	
	public static final String PROP_FILE = "xtconfig.properties";
	//数据库连接参数
	public static final boolean DEV_MODE = PropKit.use(PROP_FILE).getBoolean("devMode",false);
	public static final String JDBC_URL = PropKit.use(PROP_FILE).get("jdbcUrl","").trim();
	public static final String JDBC_USER = PropKit.use(PROP_FILE).get("user","").trim();
	public static final String JDBC_PASSWORD = PropKit.use(PROP_FILE).get("password","").trim();
	public static String JDBC_PASSWORD_UP = "";
	//redis常量
	public static final String REDIS_CACHE_NAME = PropKit.use(PROP_FILE).get("redis.cacheName","").trim();
	public static final String REDIS_HOST = PropKit.use(PROP_FILE).get("redis.host","").trim();
	public static final int REDIS_PORT = PropKit.use(PROP_FILE).getInt("redis.port",6379);
	public static final int REDIS_TIMEOUT = PropKit.use(PROP_FILE).getInt("redis.timeout",3000);
	public static final String REDIS_PASSWORD = PropKit.use(PROP_FILE).get("redis.password","").trim();
	
	public static final String REGISTER_CODE = PropKit.use(PROP_FILE).get("jpxt","").trim();
	
	public static final String REGISTER_ADDRESS = PropKit.use(PROP_FILE).get("register_address","").trim();
	public static final String REGISTER_GETPAR = PropKit.use(PROP_FILE).get("register_getPar","").trim();
	
	//用户验证相关
	public static final String stuUser_cache = "_stuUsercache_";
	public static final String access_key = "accessKey";
	public static final int PAGE_NUMBER = 1;
	public static final int PAGE_SIZE = 20;
	public static final int sutUser_cache_sec = 60*60*24*7;
	
	//短信发送
	public static final String sms_account = PropKit.use(PROP_FILE).get("sms.account","").trim();
	public static final String sms_password = PropKit.use(PROP_FILE).get("sms.password","").trim();
	
	public static String getTrainOrderPlaceCacheKey(int trainPlanId){
		return HashKit.sha1("STORDER_"+trainPlanId);
	}
	
	public static String getCourseName(int course) {
		if(course == 1){
			return "科目一";
		}else if(course == 2){
			return "科目二";
		}else if(course == 3){
			return "科目三";
		}else if(course == 4){
			return "科目四";
		}
		return "未知科目";
	}
	public static final int SMS_SEND_SECONDS = 60;
	public static final int SMS_MAX_SEND_PER_MINUTES = 5;
	public static final String CODE = "code_";
	public static final int CODE_CACHE_SEC = 120;
	
	public static String getCodeKey(String mobile){
		return CODE + mobile;
	}
	
	//app文件存储相关
	public static final String file_save_path = PropKit.use(PROP_FILE).get("fileSavePath","").trim();
	public static final String file_url = PropKit.use(PROP_FILE).get("fileUrl","").trim();
	
	public static String getFileSavePath(String type,String date){
		return file_save_path + File.separator + type +File.separator + date +File.separator;
	}
	public static String getFileUrl(String type,String date,String fileName){
		return file_url + "/" + type + "/"+ date + "/" + fileName;
	}

}
